import React from 'react';
import { Modal } from 'antd';
import ProForm, { ModalForm, ProFormText, ProFormDateTimePicker } from '@ant-design/pro-form';

const UpdateForm = (props) => {

  return (
    <ModalForm
    layout="horizontal"
    labelCol={{ span: 4 }}

    title="修改登录日志"
    width="600px"
    visible={props.updateModalVisible}
    modalProps={{
      destroyOnClose: true,
      onCancel: () =>  props.onCancel(),
    }}

    onFinish={props.onSubmit}
    initialValues={{
      infoId: props.values.infoId,
      ipaddr: props.values.ipaddr,
      loginLocation: props.values.loginLocation,
      browser: props.values.browser,
      loginTime: props.values.loginTime,
      msg: props.values.msg,
    }}
  >

<ProFormText
      name="infoId"
      hidden="true"
    />
    <ProFormText
      rules={[
        {
          required: true,
          message: '登录IP地址不能为空',
        },
        {
          pattern: new RegExp(
            '^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$',
            'g',
          ),
          message: '登录IP地址格式错误',
        },
      ]}
      width="md"
      name="ipaddr"
      label="登录IP地址"
      placeholder="请输入登录IP地址"

    />

    <ProFormText
      rules={[
        {
          required: true,
          message: '登录地点为必填项',
        },
      ]}
      width="md"
      label="登录地点"
      placeholder="请输入登录地点"
      name="loginLocation"
    />
    <ProFormText
      rules={[
        {
          required: true,
          message: '浏览器类型为必填项',
        },
      ]}
      width="md"
      label="浏览器类型"
      placeholder="请输入浏览器类型"
      name="browser"
    />

    <ProFormDateTimePicker
      name="loginTime"
      label="访问时间"
      rules={[
        {
          required: true,
          message: '访问时间为必填项',
        },
      ]}
    />
    <ProFormText
      rules={[
        {
          required: true,
          message: '提示消息为必填项',
        },
      ]}
      width="md"
      label="提示消息"
      placeholder="请输入提示消息"
      name="msg"
    />
  </ModalForm>
  );
};

export default UpdateForm;
